package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldReplaceDto;
import com.cleaningcloud.cld.domain.vo.CldReplaceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldReplace;
import com.cleaningcloud.cld.service.ICldReplaceService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 补卡管理Controller
 * 
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/CldReplace")
public class CldReplaceController extends BaseController
{
    @Autowired
    private ICldReplaceService cldReplaceService;

    /**
     * 查询补卡管理列表
     */
    @RequiresPermissions("cld:CldReplace:list")
    @GetMapping("/list")
    public TableDataInfo list(CldReplaceDto cldReplace)
    {
        startPage();
        List<CldReplaceVo> list = cldReplaceService.selectCldReplaceList(cldReplace);
        return getDataTable(list);
    }


    /**
     * 获取补卡管理详细信息
     */
    @RequiresPermissions("cld:CldReplace:query")
    @GetMapping(value = "/{replaceId}")
    public AjaxResult getInfo(@PathVariable("replaceId") Long replaceId)
    {
        return success(cldReplaceService.selectCldReplaceByReplaceId(replaceId));
    }

    /**
     * 新增补卡管理
     */
    @RequiresPermissions("cld:CldReplace:add")
    @Log(title = "补卡管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldReplaceDto cldReplace)
    {
        return toAjax(cldReplaceService.insertCldReplace(cldReplace));
    }

    /**
     * 修改补卡管理
     */
    @RequiresPermissions("cld:CldReplace:edit")
    @Log(title = "补卡管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldReplace cldReplace)
    {
        return toAjax(cldReplaceService.updateCldReplace(cldReplace));
    }

    /**
     * 审核补卡管理
     */
    @RequiresPermissions("cld:CldReplace:edit")
    @Log(title = "补卡管理", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody CldReplace cldReplace)
    {
        return toAjax(cldReplaceService.auditCldReplace(cldReplace));
    }

    /**
     * 删除补卡管理
     */
    @RequiresPermissions("cld:CldReplace:remove")
    @Log(title = "补卡管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{replaceIds}")
    public AjaxResult remove(@PathVariable Long[] replaceIds)
    {
        return toAjax(cldReplaceService.deleteCldReplaceByReplaceIds(replaceIds));
    }
}
